package com.pdstudio.carrecom.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.pdstudio.carrecom.R;
import com.pdstudio.carrecom.bean.Boutique;
import com.pdstudio.carrecom.bean.HomeInfo;
import com.pdstudio.carrecom.bean.Order;

import java.util.List;

import net.simonvt.menudrawer.Position;

/**
 * 
 * 类: BoutiqueListAdapter <br>
 * 描述: 精品展示适配器 <br>
 * 作者: ws <br>
 * 时间: 2015-5-25 下午11:22:35
 */
public class BoutiqueListAdapter extends BaseAdapter {

	private Context mContext;
	private List<Boutique> mBoutiques;
	private LayoutInflater mInflater;

	public BoutiqueListAdapter(Context context, List<Boutique> boutiques) {
		mContext = context;
		mBoutiques = boutiques;
		mInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		return mBoutiques.size();
	}

	@Override
	public Object getItem(int i) {
		return mBoutiques.get(i);
	}

	@Override
	public long getItemId(int i) {
		return i;
	}

	@Override
	public View getView(int i, View view, ViewGroup viewGroup) {

		ViewHolder viewHolder;

		if (view == null) {
			viewHolder = new ViewHolder();
			view = mInflater.inflate(R.layout.item_listview_boutique,
					viewGroup, false);
			viewHolder.mTitle = (TextView) view
					.findViewById(R.id.boutique_title);
			viewHolder.mName = (TextView) view.findViewById(R.id.boutique_name);
			viewHolder.mPrice = (TextView) view
					.findViewById(R.id.boutique_price);
			viewHolder.mDesc = (TextView) view.findViewById(R.id.boutique_desc);
			viewHolder.mImage = (ImageView) view.findViewById(R.id.boutique_img);

			view.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) view.getTag();
		}

		viewHolder.mTitle.setText(mBoutiques.get(i).getTitle());
		viewHolder.mName.setText(mBoutiques.get(i).getMerchant_name());
		viewHolder.mPrice.setText("价格：" + mBoutiques.get(i).getPrice() + "万元");
		viewHolder.mDesc.setText(mBoutiques.get(i).getDesc());
		
		switch (i) {
		case 0:
			viewHolder.mImage.setImageResource(R.drawable.benz10);
			break;
		case 1:
			viewHolder.mImage.setImageResource(R.drawable.benz11);
			break;
		case 2:
			viewHolder.mImage.setImageResource(R.drawable.benz12);
			break;
		case 3:
			viewHolder.mImage.setImageResource(R.drawable.benz13);
			break;
		case 4:
			viewHolder.mImage.setImageResource(R.drawable.benz14);
			break;
		case 5:
			viewHolder.mImage.setImageResource(R.drawable.benz15);
			break;
		case 6:
			viewHolder.mImage.setImageResource(R.drawable.benz16);
			break;
		case 7:
			viewHolder.mImage.setImageResource(R.drawable.benz17);
			break;
		case 8:
			viewHolder.mImage.setImageResource(R.drawable.benz18);
			break;
		case 9:
			viewHolder.mImage.setImageResource(R.drawable.benz19);
			break;

		default:
			break;
		}
		
		return view;
	}

	class ViewHolder {
		private TextView mTitle;
		private TextView mName;
		private TextView mPrice;
		private TextView mDesc;
		private ImageView mImage;
	}
}
